function output = rhythm_gpu(y);
if nargin < 1, y = wavread('technobeat.wav'); end

bandlimits=gsingle([0 200 400 800 1600 3200]);
numBands = length(bandlimits);
maxfreq=44100;
y = gsingle(y);
hannWinLength = .4;


hannlen = hannWinLength*2*maxfreq;

yFFTed = fft(y);
n = length(yFFTed);
bl = gzeros(6,1);
br = gzeros(6,1);
i = [];

gfor i = 1:numBands-1
    bl(i) = floor(bandlimits(i)/maxfreq*n/2)+1;
    br(i) = floor(bandlimits(i+1)/maxfreq*n/2);
    
gend

bl(numBands) = floor(bandlimits(numBands)/maxfreq*n/2)+1;
br(numBands) = floor(n/2);

output = gzeros(n,numBands);



for i = 1:numBands
    output(bl(i):br(i),i) = yFFTed(bl(i):br(i));
    output(n+1-br(i):n+1-bl(i),i) = yFFTed(n+1-br(i):n+1-bl(i));
end

output(1,1)=0;


wave = gones(size(output));
freq = gones(size(wave));


hann = [zeros(n,1)];
%for the (relatively) small value of hannlen, it's slower to use the GPU
for a = 1:hannlen
    hann(a) = (cos(a*pi/hannlen/2)).^2;
end
hann = gsingle(hann);


gfor k = 1:numBands
    wave(:,k) = real(ifft(output(:,k)));
gend


% for i = 1:numBands
%     j = [];
%     gfor j = 1:n
%         condition = wave(j,i) < 0;
%         wave(j,i) = ~condition*wave(j,i) + condition*-wave(j,i);
%     gend    
% end


freq = fft(abs(wave));


i = [];
gfor i = 1:numBands
    output(:,i) = real(ifft(freq(:,i).*fft(hann)));
gend
